<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <!-- import CSS -->
    <link rel="stylesheet" href="https://cdn.staticfile.org/element-ui/2.15.9/theme-chalk/index.css">
    <style>
        .el-page-header__content{
            color: white;
        }
    </style>
</head>
<body>
<div id="app">
    <el-page-header style="background-color: #363636;color: white;line-height: 60px"
                    @back="goBack" content="添加管理员信息">
    </el-page-header>
    <div style="margin: 0 auto">
        <img src="img/logo.jpg" style="margin-left: 700px">
    </div>
    <el-card style="width: 600px;height: 700px;margin: 0 auto">
        <el-form label-width="80px">
            <el-form-item label="管理员身份">
                <el-input v-model="a.post" type="text"></el-input>
            </el-form-item>
            <el-form-item label="管理员账户">
                <el-input v-model="a.name" type="text"></el-input>
            </el-form-item>
            <el-form-item label="管理员密码">
                <el-input v-model="a.password" type="text"></el-input>
            </el-form-item>

            <el-form-item>
                <el-button type="success" @click="insert()">添加信息</el-button>
            </el-form-item>
        </el-form>
    </el-card>
</div>
</body>
<!--引入axios和vue框架文件-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>=
<!-- import Vue before Element -->
<script src="https://cdn.staticfile.org/vue/2.6.14/vue.min.js"></script>
<!-- import JavaScript -->
<script src="https://cdn.staticfile.org/element-ui/2.15.9/index.min.js"></script>
<script>
    let v = new Vue({
        el: '#app',
        data: function () {
            return {
                a: {
                    post:"",
                    name:"",
                    password:""
                }
            }
        },
        methods: {
            //添加
            insert(){
                if(v.a.post=="" || v.a.name=="" || v.a.password==""){
                    confirm("信息不允许为空，请重新填写")
                    return;
                }
                axios.post("/admin/insert",v.a).then(function(response){
                    location.href="/person.html"
                })
            },
            goBack() {
                //返回上一页面
                history.back();
            },
        },
    })
</script>
</html>